
//P-2058
#include<iostream>
#include<queue>

using namespace std;

const int N = 1e5 + 10;
typedef pair<int, int>PII;
int num[N];
int kinds;

queue<PII>q;

int main()
{
	int a; cin >> a;
	while (a--)
	{
		int time, peo; cin >> time >> peo;
		{
			for (int i = 1; i <= peo; i++)
			{
				int x; cin >> x;
				q.push({ time,x });
				if (num[x]++ == 0)
				{
					kinds++;
				}
			}
			while(q.size()&&q.back().first-q.front().first>=86400)
			{
				int x = q.front().second;
				q.pop();
				if (num[x]-- == 1)
				{
					kinds--;
				}
			}
		}cout << kinds << endl;
	}
	
	return 0;
}
